package dome1;

/**
 * Created with IntelliJ IDEA.
 * Description: 自定义异常实现登录
 * User: 王圆豪
 * Date: 2024-06-02
 * Time: 17:10
 */
public class Login {
    private String name;
    private String password;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void identify(String name, String password) {
        if (!this.name.equals(name)) {
            throw new NameException("用户名异常...");
        }
        if (!this.password.equals(password)) {
            throw new PasswordException("密码异常...");
        }
        System.out.println("登录成功...");
    }
}
